package com.dhj.streamTest2;

import com.dhj.streamTest.entity.Author;

import java.util.List;

import static com.dhj.streamTest.entity.AuthorList.getAuthors;

public class Demo9 {

    public static void main(String[] args) {
        List<Author> authors = getAuthors();

        Integer reduce = authors.stream().map(author -> author.getAge())
                .reduce(Integer.MIN_VALUE, (result, element) -> result > element ? result : element);
        System.out.println("年龄的最大值：" + reduce);


        System.out.println("---------------------------------");


        Integer reduce1 = authors.stream().distinct().map(author -> author.getAge())
                .reduce(Integer.MAX_VALUE, (result, ele) -> result > ele ? ele : result);

        System.out.println("年龄的最小值：" + reduce1);


    }
}
